package sort;

import common.Print;

/**
 * 冒泡排序
 */
public class BubbleSort {

    public static void main(String[] args) {
        int[] arr = {3,5,2,4,15,19,25,47,26,27,2,46,4,19,48,50};
        sort(arr);
        Print.printArr(arr);
    }

    public static void sort(int[] arr){
        for (int j = arr.length-1; j > 0; j--) {
            for (int i = 0; i < j; i++) {
                if(arr[i] >arr[i+1]){
                    int temp = arr[i+1];
                    arr[i+1] = arr[i];
                    arr[i] = temp;
                }
            }
        }

    }

}
